import * as vscode from 'vscode';
import {dedent} from "../../../utils";

// documentation中使用了代码块，代码块中写的事makedown格式，首行不能为空
let scrapePicItems = [
    {
        "label": "ScrapePic_Create",
        "insertText": dedent`
        local TT = GUI:ScrapePic_Create(\${1:parent}, \${2:"ScrapePic"}, \${3:250}, \${4:200}, \${5:"res/public/word_fubentg_11.png"}, \${6:"res/public/mask_1.png"}, \${7:18}, \${8:2}, \${9:5}, \${10:function()
            SL:Print("刮图完毕|||")
        end})
        `,
        "documentation": dedent`# 创建刮图
        ## ScrapePic_Create(parent, ID, x, y, showImg, maskImg, clearHei, moveTime, beginTime, callback)

        | 参数      | 必选 | 类型   | 注释                             |
        | :-------- | :--- | :----- | :------------------------------- |
        | parent    | 是   | obj    | 父节点对象                       |
        | ID        | 是   | string | 唯一ID                           |
        | x         | 是   | int    | 位置 横坐标                      |
        | y         | 是   | int    | 位置 纵坐标                      |
        | showImg   | 是   | string | 展示图片资源                     |
        | maskImg   | 是   | string | 遮罩图片资源                     |
        | clearHei  | 否   | int    | 刮除高度, 默认16                 |
        | moveTime  | 是   | int    | 刮除时间, 单位: 秒               |
        | beginTime | 否   | int    | 开始点击到结束触发间隔, 单位: 秒 |

        - 示例代码
        \`\`\`
        -- 刮图两秒 自动展示
        local TT = GUI:ScrapePic_Create(GUI:Attach_LeftBottom(), "ScrapePic", 250, 200, "res/public/word_fubentg_11.png", "res/public/mask_1.png", 18, 2, 5, function()
            SL:Print("刮图完毕|||")
        end)
        \`\`\`
        `
    }
]


export function getCompletionItems(): vscode.CompletionItem[] {


    const completionItems: vscode.CompletionItem[] = [];
    scrapePicItems.forEach((item: any) => {
        completionItems.push(createFunctionCompletionItem(item.label, item.insertText, item.documentation));
    });
    return completionItems;
}

function createFunctionCompletionItem(label: string, insertText: string, documentation?: string): vscode.CompletionItem {
    const item = new vscode.CompletionItem(label, vscode.CompletionItemKind.Function);
    item.insertText = new vscode.SnippetString(insertText);
    if (documentation) {
        item.documentation = new vscode.MarkdownString(documentation);
    }
    return item;
}
